<?php

namespace common\validate;

use think\Validate;

class TenantUser extends BaseValidate
{
    //验证规则
    protected $rule = [];

    // Fields 验证场景定义
    public function sceneFields()
    {
        return $this;
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }


    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'array')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // Select 验证场景定义
    public function sceneSelectTenantUser()
    {
        return $this->append('param', 'array')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data.name', 'require|max:128')
            ->append('data.code', 'max:128');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data.id', 'require')
            ->append('data.name', 'max:128')
            ->append('data.code', 'max:128');
    }


    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require');
    }

    // SetDepartments 验证场景定义
    public function sceneSetDepartments()
    {
        return $this->append('data.user_id', 'require|integer')
            ->append('data.tenant_id', 'require|integer')
            ->append('data.department_id', 'array');
    }

    // SetRoles 验证场景定义
    public function sceneSetRoles()
    {
        return $this->append('data.user_id', 'require|integer')
            ->append('data.tenant_id', 'require|integer')
            ->append('data.role_id', 'array');
    }

    // Depart 验证场景定义
    public function sceneDepart()
    {
        return $this->append('param.filter.id|租户成员id', 'require|integer');
    }

    // Entry 验证场景定义
    public function sceneEntry()
    {
        return $this->append('param.filter.id|租户成员id', 'require|integer');
    }

    // Tree 验证场景定义
    public function sceneTree()
    {
        return $this->append('param.include_employed|是否包含离职', 'in:yes,no');
    }
}
